package personal.xjl.plusdemo.spring;

import lombok.Data;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.MethodBeforeAdvice;

import java.lang.reflect.Method;

@Data
public class MyAdvice implements MethodBeforeAdvice, AfterReturningAdvice, MethodInterceptor {
    @Override
    public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
        System.out.println("---this is after advice------");
    }
    @Override
    public void before(Method method, Object[] args, Object target) throws Throwable {
        System.out.println("---this is before advice------");
    }

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        System.out.println("---this is invoke advice begin------");
        Object result = invocation.proceed();
        System.out.println("---this is invoke advice end------");
        return result;
    }
}
